import java.util.Scanner;

/**
 * @author vivi
 * @description
 * @date 2024/5/10
 */
public class demo1 {
    public static void main (String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();

        int h,a,H,A;
        while (t-- != 0){
            h = in.nextInt();
            a = in.nextInt();
            H = in.nextInt();
            A = in.nextInt();

            if(a >= H){
                System.out.println(-1);
            }else {
                //怪物被攻击的次数
                int m = H/a + (H%a == 0 ? 0 : 1);
                //玩家被攻击的次数
                int n = m - 1;
                //玩家掉的血量
                int x = A * n;
                //杀掉的怪物数量
                int ret = h/x - (h%x == 0 ? 1 : 0);

                System.out.println(ret);
            }
        }

    }
}
